import '../configs/urls_config.dart';
import '../models/admin_user_info.dart';
import '../models/paged_result.dart';
import '../api/rest.dart';

class AdminUserService {
  factory AdminUserService() => _getInstance();
  static AdminUserService get instance => _getInstance();
  static AdminUserService _instance;
  static AdminUserService _getInstance() {
    if (_instance == null) {
      _instance = AdminUserService._internal();
    }
    return _instance;
  }

  RestfulApiClient _client = RestfulApiClient<AdminUserInfo>(
    resourcePath: UrlsConfig.resourceUrls.adminUserUrl,
    fromJson: (json) => AdminUserInfo.fromJson(json),
  );

  AdminUserService._internal() {
    // nothing
  }

  Future<PagedResult<AdminUserInfo>> pagination({
    int page = 1,
    int limit = 20,
    String query,
    String orderBy,
  }) {
    return _client.pagination(
      page: page,
      limit: limit,
      query: query,
      orderBy: orderBy,
    );
  }

  Future<AdminUserInfo> getById(String id) {
    return _client.getById(id);
  }

  Future<AdminUserInfo> create(dynamic data) {
    return _client.create(data);
  }

  Future<AdminUserInfo> update(String id, dynamic data) {
    return _client.update(id, data);
  }

  Future removeById(String id) {
    return _client.removeById(id);
  }
}
